<nav class="navbar navbar-expand-lg navbar-light bg-white py-0 shadow-sm sticky-top">
    <div class="container">
        <a class="navbar-brand" href="/"><img src="<?=config('plugin.laoha.set.logo','/app/laoha/logo.svg')?>" height="45" /></a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse ms-3" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <?php 
foreach($navs as $v){ 
    if($v['type'] && !user_id()){
        continue;
    }
    $v['target'] = $v['target'] ? 'target="_blank"':'';
    $v['active']  = ($active && $v['url']==$active) ? ' active':'';     
    $v['icon'] = $v['icon'] ? '<i class="fa '.$v['icon'].'"></i> ':'';
    if(empty($v['children'])) {                  
        echo '<li class="nav-item"><a class="nav-link '.$v['active'].'" href="'.$v['url'].'" '.$v['target'].'>'.$v['icon'].$v['title'].'</a>'.PHP_EOL;
    }else{
        echo '<li class="nav-item dropdown"><a class="nav-link '.$v['active'].' dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">'.$v['icon'].$v['title'].'</a>'.PHP_EOL;
        echo '<ul class="dropdown-menu">'.PHP_EOL;
        foreach($v['children'] as $item){
            if($item['type'] && !user_id()){
                continue;
            }
            $item['icon'] = $item['icon'] ? '<i class="fa '.$item['icon'].'"></i> ':'';
            $item['target'] = $item['target'] ? 'target="_blank"':'';
            if(empty($item['children']) && $item['url']=='-'){
                echo '<li><hr class="dropdown-divider"></li>'.PHP_EOL;
            }else{
                echo '<li><a class="dropdown-item" href="'.$item['url'].'" '.$item['target'].'>'.$item['icon'].$item['title'].'</a></li>'.PHP_EOL;
            }
        }
        echo '</ul>'; 
    }
}
?>
            </ul>
            <div class="d-flex align-items-center">

                <?php if(user_id()){ ?>
                <div class="nav-item dropdown">
                    <button class="btn btn-default border-0 dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <img src="<?=user('avatar')?>" class="rounded-circle" height="40px" width="40px" /> <?=user('nickname')?>
                    </button> 
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="/app/laoha/user/index">会员中心</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item " href="javascript:;" onclick="logout('/app/laoha/user/logout')">退出</a></li>
                    </ul>
                </div>
                <?php }else{ ?>
                <a href="/app/laoha/user/login" class="btn btn-primary ajax-popup-link">登录</a>&nbsp;&nbsp;
                <a href="/app/user/register" class="btn btn-outline-primary" >注册</a>
                <?php } ?>

            </div> 
        </div>
    </div>
</nav>